﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;

namespace Chess.Common.Network
{
    internal static class NetworkUtilities
    {
        public static XmlSerializer BuildSerializer()
        {
            Type networkData = typeof(NetworkData);
            IEnumerable<Type> types = Assembly.GetCallingAssembly().GetTypes()
                                                                   .Where(type => type.IsSubclassOf(networkData));

            return new XmlSerializer(typeof(NetworkPacket), types.ToArray());
        }
    }
}
